home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 September / EnigmA AMIGA RUN 10 (1996)(G.R. Edizioni)(IT)[!][issue 1996-09][EARSAN CD XI].iso / aweb / awebmailsend.rexx < prev   
OS/2 REXX Batch file  |  1996-03-24  |  6KB  |  173 lines

  1. /* Inline mail send arexx script for Aweb (w/ Voodoo Launch Option!)
  2.  
  3.     Version 1.0a
  4.  
  5.     By Josef Faulkner (panther@gate.net) IRC: Josef
  6.  
  7.     Description:
  8.     ¯¯¯¯¯¯¯¯¯¯¯
  9.     This script is a mailto: plugin for Aweb.  This script will be run in
  10.     response to mailto: URLs, and will allow you to either compose a message
  11.     inside Aweb's GUI and send it, with NO need for any SMTP mailers, or you
  12.     can Launch Voodoo and let it handle the job.
  13.  
  14.     Features:
  15.     ¯¯¯¯¯¯¯¯¯
  16.         o Does not need an external SMTP mail program, does network stuff itself
  17.         if you have the TCP: network device installed.
  18.         o Can launch Voodoo instead, and this script will pass it the screenname
  19.           and address, and fill in a default subject.
  20.         o Runs transparently.  After you install, you don't even know it's there.
  21.         o Loads your signature into the <textarea> gadget.
  22.  
  23.     Installation:
  24.     ¯¯¯¯¯¯¯¯¯¯¯¯¯
  25.     1) Put this script in the same directory that the Aweb executable is in.
  26.     2) Set Aweb to the following settings:
  27.       ----------------------------------------------
  28.         Network 3: External Programs
  29.                    mailto:
  30.           Command:  sys:rexxc/rx
  31.         Arguments:  awebmailsend.rexx %s %s
  32.       ----------------------------------------------
  33.         Network 1: General
  34.         [ X ] Allow Shell commands in Links (check on)
  35.       ----------------------------------------------
  36.     3) Set your preferences for this script below:
  37. */
  38.  
  39. /* >--[ Settings - Customize for your system ]------------------------< */
  40. SMTPHost   = 'tequesta.gate.net'   /* Name of your SMTP host */
  41. VooDoo = 'N:Voodoo/Voodoo'         /* Voodoo's location on your drive */
  42. signature='DH2:net/.signature'         /* Location of your .signature */
  43. myemailaddress=''                  /* Set to your email address, or leave
  44.                                       blank, and it will look up your email
  45.                                       address from your ENV variables */
  46. /* Main Script */
  47. options results
  48. if ~show('L','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then exit(20)
  49. parse arg addr
  50.  
  51. address command 'delete T:awebmail.#?.html >NIL:'
  52. fname='T:AwebMail.'time(S)'.html'
  53. if (~exists('env:username'))|(~exists('env:hostname')) then do
  54.     call open(4,fname,w)
  55.     call writeln(4,'<html><head><title>Error</title></head><body>')
  56.     call writeln(4,'<h1>Error</h1>')
  57.     call writeln(4,'<b>You have not configured your USERNAME and HOSTNAME env variables.</b><br>')
  58.     call writeln(4,'Could not send mail.  Please set these variables and re-try')
  59.     call close(4)
  60.     address AWEB.1 'OPEN file://localhost/'fname
  61.     exit
  62. end
  63. if left(addr,8)~='address=' then do
  64.     parse var addr addr' 'screen
  65.     if open(1,fname,w) then do
  66.         call writeln(1,'<html><head><title>')
  67.         call writeln(1,addr)
  68.         call writeln(1,'</title></head><body><h1>Mail to ')
  69.         call writeln(1,addr'</h1>')
  70.         call writeln(1,'<hr><form action="x-aweb:command/'voodoo' mail to 'addr' subject mailto:'addr' pubscreen 'screen'">')
  71.         call writeln(1,'<input type="submit" value="Use VooDoo!"><hr></form>')
  72.         call writeln(1,'<form action="x-aweb:rexx/awebmailsend.rexx">')
  73.         call writeln(1,'<tt>Mail to: <input size=60 name="address" value="'addr'"><br>')
  74.         call writeln(1,'Subject: <input size=75 name="subj" value="mailto:'addr'"><br>')
  75.         call writeln(1,'Mail text:</tt><hr>')
  76.         if exists(signature) then do
  77.             call writeln(1,'<textarea name="data" cols=75 rows=20>')
  78.             do n=1 to 4
  79.                 call writeln(1,'')
  80.             end
  81.             call writeln(1,'--')
  82.             call open(2,signature,r)
  83.             do until eof(2)
  84.                 call writeln(1,readln(2))
  85.             end
  86.             call close(2)
  87.             call writeln(1,'</textarea>')
  88.         end
  89.         else do
  90.             call writeln(1,'<textarea name="data" cols=75 rows=20></textarea>')
  91.         end
  92.         call writeln(1,'<hr><input type="submit" value="Send Mail"></form>')
  93.         call writeln(1,'</body></html>')
  94.         call close(1)
  95.         address AWEB.1 'OPEN file://localhost/'fname
  96.     end
  97.     else address command 'RequestChoice "MailToRexx" "Error" "Ok" >NIL:'
  98. end
  99. else do
  100.     if open(1,fname,w) then do
  101.         call open(99,'t:test',w)
  102.         call writeln(99,addr)
  103.         call close(99)
  104.         parse var addr 'address="'touser'" subj="'subj'" data="'otext
  105.         otext=left(otext,length(otext)-1)
  106.         otext=replace(otext,'*"','"')
  107.         otext=replace(otext,'*N',d2c(10))
  108.  
  109.         if myemailaddress='' then do
  110.             call open(7,'env:username',r)
  111.                 fromid=readln(7)
  112.             call close(7)
  113.             call open(7,'env:hostname',r)
  114.                 fromhost=readln(7)
  115.             call close(7)
  116.             from=fromid'@'fromhost
  117.         end
  118.         else from=myemailaddress
  119.  
  120.         data=replace(data,'.'d2c(13),'. 'd2c(13))
  121.         if exists('T:SentMail.txt') then call open(10,'T:SentMail.txt',a)
  122.         else call open(10,'T:SentMail.txt',w)
  123.         call writeln(10,'From: <'from'>')
  124.         call writeln(10,'To: 'touser)
  125.         call writeln(10,'Subject 'subj)
  126.         call writeln(10,'')
  127.         call writeln(10,otext)
  128.         call close(10)
  129.  
  130.         if ~showlist(H,'TCP') then address command 'mount TCP: from amitcp:devs/inet-mountlist'
  131.         if ~showlist(H,'TCP') then address command 'mount TCP:'
  132.         if showlist(H,'TCP') then do
  133.             call open(8,'tcp:'smtphost'/25',w)
  134.             call writeln(8,'HELO')
  135.             call writeln(8,'MAIL FROM: '||from)
  136.             call writeln(8,'RCPT TO: '||touser)
  137.             call writeln(8,'DATA')
  138.             call writeln(8,'From: <'from'>')
  139.             call writeln(8,'To: 'touser)
  140.             call writeln(8,'Subject: 'subj)
  141.             call writeln(8,'')
  142.             call writeln(8,otext)
  143.             call writeln(8,'.')
  144.             call writeln(8,'QUIT')
  145.             call close(8)
  146.         end
  147.         else do
  148.             address command 'Requestchoice title="SMTPSend" BODY="Mail NOT sent.  *nCouldn''t mount TCP:" GADGETS="Ok" >NIL:'
  149.             exit
  150.         end
  151.  
  152.         otext=replace(otext,'<','<')
  153.         otext=replace(otext,'>','>')
  154.         call writeln(1,'<html><head><title>Mail to 'touser'</title></head><body>')
  155.         call writeln(1,'<h1>Mail sent to 'touser':</h1>')
  156.         call writeln(1,'<h2>'subj'</h2><pre>'otext)
  157.         call writeln(1,'</pre></body></html>')
  158.         call close(1)
  159.         address AWEB.1 'OPEN file://localhost/'fname
  160.     end
  161.     else address command 'Requestchoice title="SMTPSend" BODY="Mail Sent." GADGETS="Ok" >NIL:'
  162. end
  163. exit
  164.  
  165. REPLACE: procedure
  166. parse arg a,b,c
  167. d=index(a,b)
  168. do while d~=0
  169.     a=insert(c,delstr(a,d,length(b)),d-1)
  170.     d=index(a,b)
  171. end
  172. return a
  173.